$(document).ready(function () {
    //按钮单击时执行
    $("#submit").on("click", function () {
        var userName = document.getElementById("userName").value;
        var password = document.getElementById("password").value;
        var data = "userName=" + userName + "&password=" + password;
        $.ajax({
            "url": url + loginUrl,
            "type": 'post',
            "data": data,
            "dataType": "json",
            "success": function (data) {
                var res = eval('(' + JSON.stringify(data) + ')');
                if (res.resultCode != 200) {
                    error(data);
                    return;
                }
                var user = JSON.stringify(res.obj);
                localStorage.setItem(schoolLoginUserInfo, user);
                var res = eval('(' + user + ')');
                if (res.role == 4) {
                    window.location.href = "html\\index.html";
                } else {
                    window.location.href = "html\\reception.html";
                }
            },
            "error": error()
        })
    })
})